#include "stdafx.h"
#include "QueObj.h"
#include "U32Queue.h"


U32Queue::U32Queue()
{
	m_pFront = 0;
	m_pBack = 0;
	count = 0;
}


U32Queue::~U32Queue()
{
	while (m_pFront != 0) {
		Pop();
	}
}


void U32Queue::Push(u32 baseADDR)
{
	QueObj* obj = new QueObj(baseADDR);
	
	if (m_pFront == 0) {
		m_pFront = obj;
		m_pBack = obj;
	}
	else {
		m_pBack->next = obj;
		m_pBack = obj;
	}	

	count++;
}


u32 U32Queue::Pop()
{
	if (m_pFront == 0)return 0;

	QueObj* tmp = m_pFront;
	int ret= m_pFront->m_nBaseAddr;

	m_pFront = m_pFront->next;

	delete tmp;
	count--;

	return ret;
}


int U32Queue::Size()
{
	return count;
}


